package main

import (
	"encoding/json"
	"fmt"
)

type struct_Monster1 struct {
	Name string `json:"name"`
	Age int `json:"age"`
	Birthday string
	Sal float64
	Skill string
}

//对struct序列化
//如果指定tag则会将序列化的key改为tag的值
func testMonster1(){
	monster := struct_Monster1{
		Name:"hahaha",
		Age:20,
		Birthday:"2020-01-01",
		Sal:34.5,
		Skill:"大锤",
	}

	data, err := json.Marshal(&monster)
	if err != nil{
		fmt.Println("序列化失败", err)
		return
	}
	fmt.Println(string(data))
}

func main() {
	testMonster1()
}